Imports System.Configuration

Public Class frmPosMain
    Inherits System.Windows.Forms.Form
    Public LogFlag As Integer
    Public ImagePath As String = ConfigurationManager.AppSettings("ImagePath")
    Public MainTitle As String
    Public SaleSumRpt As Object
    Public ProdSaleRpt As Object
    Public DiscountRpt As Object
    Public PrchangeRpt As Object
    Public dmgrpt As Object
    Public matdrpt As Object
    Public ordrpt As Object
    Public shwrpt As Object
    Public delrpt As Object
    Public posrpt As Object
    Public rgdrpt As Object
    Public mdrpt As Object
    Public porpt As Object
    Public srrpt As Object
    Public dnrpt As Object
   
    Dim InvForm As Object
    Dim GvsForm As Object
    Dim RtnForm As Object
    Dim PrqForm As Object
    Dim EvpForm As Object
    Dim CvpForm As Object
    Dim CrqForm As Object
    Dim ProdForm As Object
    Dim EmlForm As Object
    Dim GrpForm As Object
    Dim TrfForm As Object
    Dim SaleRpt As Object
    Dim StockRpt As Object
    Dim frmProdDistrRpt As Object
    Dim PriceRpt As Object
    Dim ProdHistoryRpt As Object
    Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents PointOfSalePOSToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents SalesInvoiceToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents SalesReturnToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ItemEnquiryToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents POSReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents POSSalesReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ProductDistributionToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents PriceReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents POSSalesSummaryReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents POSProductSalesReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents RetailPriceChangeReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents RetailSalesmenPerformanceToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Dim ProdRelationRpt As Object

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ttPosMenu As System.Windows.Forms.ToolTip
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.ttPosMenu = New System.Windows.Forms.ToolTip(Me.components)
        Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
        Me.PointOfSalePOSToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.SalesInvoiceToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.SalesReturnToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.ItemEnquiryToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.POSReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.POSSalesReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.POSSalesSummaryReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.POSProductSalesReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.RetailPriceChangeReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.RetailSalesmenPerformanceToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.ProductDistributionToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.PriceReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.MenuStrip1.SuspendLayout()
        Me.SuspendLayout()
        '
        'MenuStrip1
        '
        Me.MenuStrip1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.PointOfSalePOSToolStripMenuItem, Me.POSReportToolStripMenuItem})
        Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
        Me.MenuStrip1.Name = "MenuStrip1"
        Me.MenuStrip1.Size = New System.Drawing.Size(1015, 26)
        Me.MenuStrip1.TabIndex = 144
        Me.MenuStrip1.Text = "MenuStrip1"
        '
        'PointOfSalePOSToolStripMenuItem
        '
        Me.PointOfSalePOSToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.SalesInvoiceToolStripMenuItem, Me.SalesReturnToolStripMenuItem, Me.ItemEnquiryToolStripMenuItem})
        Me.PointOfSalePOSToolStripMenuItem.Name = "PointOfSalePOSToolStripMenuItem"
        Me.PointOfSalePOSToolStripMenuItem.Size = New System.Drawing.Size(136, 22)
        Me.PointOfSalePOSToolStripMenuItem.Text = "Point Of Sale - POS"
        '
        'SalesInvoiceToolStripMenuItem
        '
        Me.SalesInvoiceToolStripMenuItem.Name = "SalesInvoiceToolStripMenuItem"
        Me.SalesInvoiceToolStripMenuItem.Size = New System.Drawing.Size(156, 22)
        Me.SalesInvoiceToolStripMenuItem.Text = "Sales Invoice"
        '
        'SalesReturnToolStripMenuItem
        '
        Me.SalesReturnToolStripMenuItem.Name = "SalesReturnToolStripMenuItem"
        Me.SalesReturnToolStripMenuItem.Size = New System.Drawing.Size(156, 22)
        Me.SalesReturnToolStripMenuItem.Text = "Sales Return"
        '
        'ItemEnquiryToolStripMenuItem
        '
        Me.ItemEnquiryToolStripMenuItem.Name = "ItemEnquiryToolStripMenuItem"
        Me.ItemEnquiryToolStripMenuItem.Size = New System.Drawing.Size(156, 22)
        Me.ItemEnquiryToolStripMenuItem.Text = "Item Enquiry"
        '
        'POSReportToolStripMenuItem
        '
        Me.POSReportToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.POSSalesReportToolStripMenuItem, Me.POSSalesSummaryReportToolStripMenuItem, Me.POSProductSalesReportToolStripMenuItem, Me.RetailPriceChangeReportToolStripMenuItem, Me.RetailSalesmenPerformanceToolStripMenuItem, Me.ProductDistributionToolStripMenuItem, Me.PriceReportToolStripMenuItem})
        Me.POSReportToolStripMenuItem.Name = "POSReportToolStripMenuItem"
        Me.POSReportToolStripMenuItem.Size = New System.Drawing.Size(98, 22)
        Me.POSReportToolStripMenuItem.Text = "POS - Report"
        '
        'POSSalesReportToolStripMenuItem
        '
        Me.POSSalesReportToolStripMenuItem.Name = "POSSalesReportToolStripMenuItem"
        Me.POSSalesReportToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.POSSalesReportToolStripMenuItem.Text = "POS - Sales Report"
        '
        'POSSalesSummaryReportToolStripMenuItem
        '
        Me.POSSalesSummaryReportToolStripMenuItem.Name = "POSSalesSummaryReportToolStripMenuItem"
        Me.POSSalesSummaryReportToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.POSSalesSummaryReportToolStripMenuItem.Text = "POS - Sales Summary Report"
        '
        'POSProductSalesReportToolStripMenuItem
        '
        Me.POSProductSalesReportToolStripMenuItem.Name = "POSProductSalesReportToolStripMenuItem"
        Me.POSProductSalesReportToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.POSProductSalesReportToolStripMenuItem.Text = "POS - Product Sales Report"
        '
        'RetailPriceChangeReportToolStripMenuItem
        '
        Me.RetailPriceChangeReportToolStripMenuItem.Name = "RetailPriceChangeReportToolStripMenuItem"
        Me.RetailPriceChangeReportToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.RetailPriceChangeReportToolStripMenuItem.Text = "Retail Price Change Report"
        '
        'RetailSalesmenPerformanceToolStripMenuItem
        '
        Me.RetailSalesmenPerformanceToolStripMenuItem.Name = "RetailSalesmenPerformanceToolStripMenuItem"
        Me.RetailSalesmenPerformanceToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.RetailSalesmenPerformanceToolStripMenuItem.Text = "Retail Salesmen Performance"
        '
        'ProductDistributionToolStripMenuItem
        '
        Me.ProductDistributionToolStripMenuItem.Name = "ProductDistributionToolStripMenuItem"
        Me.ProductDistributionToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.ProductDistributionToolStripMenuItem.Text = "Product Distribution"
        '
        'PriceReportToolStripMenuItem
        '
        Me.PriceReportToolStripMenuItem.Name = "PriceReportToolStripMenuItem"
        Me.PriceReportToolStripMenuItem.Size = New System.Drawing.Size(258, 22)
        Me.PriceReportToolStripMenuItem.Text = "Price Report"
        '
        'Panel1
        '
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel1.Location = New System.Drawing.Point(0, 26)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(1015, 447)
        Me.Panel1.TabIndex = 145
        '
        'frmPosMain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.Color.SlateGray
        Me.ClientSize = New System.Drawing.Size(1015, 473)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.MenuStrip1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.IsMdiContainer = True
        Me.MaximizeBox = False
        Me.Name = "frmPosMain"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Retail POS"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.MenuStrip1.ResumeLayout(False)
        Me.MenuStrip1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private Sub PosMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ValidUser = True
        LogFlag = 1

        Me.Text = Me.Text + " (User:" & UserName & "/" + CompanyTitle + "-" + LoginYear + ")"

    End Sub

    Private Function PanelEmpty() As Boolean
        If Panel1.Controls.Count > 0 Then
            Dim ActiveCtrl As String
            ActiveCtrl = Panel1.Controls.Item(0).Name
            Select Case ActiveCtrl
                Case "ICretailInvoice"
                    Dim cm As CurrencyManager = BindingContext(InvForm.DataGrid1.DataSource, InvForm.DataGrid1.DataMember)
                    Dim dv As DataView = cm.List
                    Dim mrow As Integer
                    mrow = dv.Table.Rows.Count
                    If mrow > 0 Then
                        PanelEmpty = False
                    Else
                        PanelEmpty = True
                    End If
                Case "ICretailReturn"
                    Dim cm As CurrencyManager = BindingContext(RtnForm.DataGrid1.DataSource, RtnForm.DataGrid1.DataMember)
                    Dim dv As DataView = cm.List
                    Dim mrow As Integer
                    mrow = dv.Table.Rows.Count
                    If mrow > 0 Then
                        PanelEmpty = False
                    Else
                        PanelEmpty = True
                    End If
                Case Else
                    PanelEmpty = True
            End Select
        Else
            PanelEmpty = True
        End If
    End Function
    Dim InvPOS As Object
    Private Sub SalesInvoiceToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SalesInvoiceToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 80) = True Then
            Panel1.Controls.Clear()
            If InvForm Is Nothing Then
                InvPOS = New frmRetailInvoice
                InvPOS.MdiParent = Me
            End If
            Panel1.Controls.Add(InvPOS)
            InvPOS.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub
    Dim frmPOSRtn As Object
    Private Sub SalesReturnToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SalesReturnToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 81) = True Then
            Panel1.Controls.Clear()
            If RtnForm Is Nothing Then
                frmPOSRtn = New frmRetailInvReturn
                frmPOSRtn.MdiParent = Me
            End If
            Panel1.Controls.Add(frmPOSRtn)
            frmPOSRtn.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub ItemEnquiryToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ItemEnquiryToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 82) = True Then
            Panel1.Controls.Clear()
            If ProdForm Is Nothing Then
                ProdForm = New frmProductMasterView
                ProdForm.MdiParent = Me
            End If
            Panel1.Controls.Add(ProdForm)
            ProdForm.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub POSSalesReportToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles POSSalesReportToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 83) = True Then
            Panel1.Controls.Clear()
            If SaleRpt Is Nothing Then
                SaleRpt = New frmPosSalesReport
                SaleRpt.MdiParent = Me
            End If
            Panel1.Controls.Add(SaleRpt)
            SaleRpt.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Dim frmRptDistr As Object
    Private Sub ProductDistributionToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ProductDistributionToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 88) = True Then
            Panel1.Controls.Clear()
            If StockRpt Is Nothing Then
                frmRptDistr = New frmProductDistributionReport
                frmRptDistr.MdiParent = Me
            End If
            Panel1.Controls.Add(frmRptDistr)
            frmRptDistr.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub
    Dim RptPrice As Object

    Private Sub PriceReportToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PriceReportToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 89) = True Then
            Panel1.Controls.Clear()
            If PriceRpt Is Nothing Then
                RptPrice = New frmPriceReport
                RptPrice.MdiParent = Me
            End If
            Panel1.Controls.Add(RptPrice)
            RptPrice.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub POSSalesSummaryReportToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles POSSalesSummaryReportToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 84) = True Then
            Panel1.Controls.Clear()
            If SaleSumRpt Is Nothing Then
                SaleSumRpt = New PosSalesSumamryRpt
                SaleSumRpt.MdiParent = Me
            End If
            Panel1.Controls.Add(SaleSumRpt)
            SaleSumRpt.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub POSProductSalesReportToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles POSProductSalesReportToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 85) = True Then
            Panel1.Controls.Clear()
            If ProdSaleRpt Is Nothing Then
                ProdSaleRpt = New frmProductSalesReport
                ProdSaleRpt.MdiParent = Me
            End If
            Panel1.Controls.Add(ProdSaleRpt)
            ProdSaleRpt.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub RetailPriceChangeReportToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RetailPriceChangeReportToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 86) = True Then
            Panel1.Controls.Clear()
            If PrchangeRpt Is Nothing Then
                PrchangeRpt = New frmPriceChangeReport
                PrchangeRpt.MdiParent = Me
            End If
            Panel1.Controls.Add(PrchangeRpt)
            PrchangeRpt.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        ApData = Nothing
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub RetailSalesmenPerformanceToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RetailSalesmenPerformanceToolStripMenuItem.Click
        Me.Cursor = Cursors.WaitCursor
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 87) = True Then
            Panel1.Controls.Clear()
            Dim salesmanPerformanceReport As New frmRetailSalesmenPerformanceReport
            salesmanPerformanceReport.MdiParent = Me
            Panel1.Controls.Add(salesmanPerformanceReport)
            salesmanPerformanceReport.Location = New Point(15, 15)
            salesmanPerformanceReport.Show()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
        Me.Cursor = Cursors.Default
    End Sub
End Class
